home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / Param.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  3.9 KB  |  138 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.DataInputStream;
  4. import java.io.DataOutputStream;
  5. import java.io.FilterInputStream;
  6. import java.io.IOException;
  7. import java.util.Vector;
  8. import symjava.sql.SQLException;
  9.  
  10. public class Param extends Field {
  11.    // $FF: renamed from: _v java.util.Vector
  12.    Vector field_0;
  13.  
  14.    private NetData getFirstDataBlock() throws SQLException {
  15.       try {
  16.          return (NetData)this.field_0.elementAt(0);
  17.       } catch (Exception var1) {
  18.          throw new SQLException("Data field not initialized");
  19.       }
  20.    }
  21.  
  22.    public Param(int id, byte[] data) {
  23.       super._id = id;
  24.       super._type = 108;
  25.       this.field_0 = new Vector();
  26.       this.field_0.addElement(new NetData(data));
  27.    }
  28.  
  29.    public Param(int id, byte[] data, int len) {
  30.       super._id = id;
  31.       super._type = 108;
  32.       this.field_0 = new Vector();
  33.       this.field_0.addElement(new NetData(data, len));
  34.    }
  35.  
  36.    public Param(int id, short data) {
  37.       super._id = id;
  38.       super._type = 100;
  39.       this.field_0 = new Vector();
  40.       this.field_0.addElement(new NetData(data));
  41.    }
  42.  
  43.    public Param(int id, boolean data) {
  44.       super._id = id;
  45.       super._type = 104;
  46.       this.field_0 = new Vector();
  47.       this.field_0.addElement(new NetData(data));
  48.    }
  49.  
  50.    public Param(int id, int data) {
  51.       super._id = id;
  52.       super._type = 101;
  53.       this.field_0 = new Vector();
  54.       this.field_0.addElement(new NetData(data));
  55.    }
  56.  
  57.    public Param(int id, int data, boolean objRef) {
  58.       super._id = id;
  59.       if (objRef) {
  60.          super._type = 107;
  61.       } else {
  62.          super._type = 101;
  63.       }
  64.  
  65.       this.field_0 = new Vector();
  66.       this.field_0.addElement(new NetData(data));
  67.    }
  68.  
  69.    public Param(int id, long data) {
  70.       super._id = id;
  71.       super._type = 103;
  72.       this.field_0 = new Vector();
  73.       this.field_0.addElement(new NetData(data));
  74.    }
  75.  
  76.    public Param(int id, float data) {
  77.       super._id = id;
  78.       super._type = 105;
  79.       this.field_0 = new Vector();
  80.       this.field_0.addElement(new NetData(data));
  81.    }
  82.  
  83.    public Param(int id, double data) {
  84.       super._id = id;
  85.       super._type = 106;
  86.       this.field_0 = new Vector();
  87.       this.field_0.addElement(new NetData(data));
  88.    }
  89.  
  90.    public Param() {
  91.       super._id = 0;
  92.       super._type = 0;
  93.       this.field_0 = new Vector();
  94.    }
  95.  
  96.    int getType() {
  97.       return 57;
  98.    }
  99.  
  100.    void read(DataInputStream in) throws SQLException, IOException, ErrorException {
  101.       in.readShort();
  102.       byte[] leader = new byte[4];
  103.       in.readFully(leader, 0, 4);
  104.       super._id = ((FilterInputStream)in).read();
  105.       super._type = ((FilterInputStream)in).read();
  106.       this.field_0 = new Vector();
  107.  
  108.       while(true) {
  109.          ServerObject obj = (ServerObject)NetClass.getNextObject(in);
  110.          if (obj.getType() == 51) {
  111.             this.field_0.addElement(obj);
  112.          } else {
  113.             if (obj.getType() == 50) {
  114.                return;
  115.             }
  116.  
  117.             ((ServerObject)this).onObjectError(obj);
  118.          }
  119.       }
  120.    }
  121.  
  122.    void write(DataOutputStream out) throws IOException {
  123.       out.writeByte(this.getType());
  124.       out.writeShort(6);
  125.       out.writeBytes("FLD}");
  126.       out.writeByte(super._id);
  127.       out.writeByte(super._type);
  128.  
  129.       for(int i = 0; i < this.field_0.size(); ++i) {
  130.          NetData d = (NetData)this.field_0.elementAt(i);
  131.          d.write(out);
  132.       }
  133.  
  134.       EOT eot = new EOT();
  135.       eot.write(out);
  136.    }
  137. }
  138.